import { RouteLocationNormalized } from 'vue-router'

// 将 store 模块 tag 中的 cacheList 转换为 name 组成的数组并返回
function routeLocations2NameArray(routes: RouteLocationNormalized[]) {
  if (!routes || routes.length <= 0) return []
  return routes.map((item) => item.name || '')
}

function routeLocation2FlatObj(route: RouteLocationNormalized) {
  console.log('即将被转换的路由对象是：', route)
  const ret = {
    name: route.name,
    title: route.meta.title,
    path: route.path,
    closable: route.meta.closable
  }
  console.log('flatObj是：', ret)
  return ret
}

export { routeLocations2NameArray, routeLocation2FlatObj }
